<?php
/**
 * Created by PhpStorm.
 * User: 宅十三
 * Date: 2021/11/22
 * Time: 11:14
 */
namespace app\demo\controller;

use think\facade\Db;
use think\facade\Request;
use think\facade\View;

class Order {
   public function orderList(){
       $where=[];
       $get=Request::get();
       if(isset($get['keywords'])) $where[]=['order_sn',"like","%".$get['keywords']."%"];
       if(isset($get['mintime'])&&!empty($get['mintime'])) $where[]=['addtime',">",strtotime($get['mintime'])];
       if(isset($get['maxtime'])&&!empty($get['maxtime'])) $where[]=['addtime',"<",strtotime($get['maxtime'])];
       if(isset($get['minqian'])&&!empty($get['minqian'])) $where[]=['price',">",$get['minqian']];
       if(isset($get['maxqian'])&&!empty($get['maxqian'])) $where[]=['price',"<",$get['maxqian']];
       if(isset($get['cid'])&&!empty($get['cid'])) $where[]=['status',"=",$get['cid']];


       $list=Db::name('order')
           ->alias('o')
           ->join('ecm_order_status s','o.status=s.status_id')
           ->field('o.*,s.order_status')
           ->where($where)
           ->paginate([
               'list_rows'=>2,
               'query'=>$get
           ]);
       View::assign('list',$list);

       $ddzt=Db::name('order_status')->select();
       View::assign('ddzt',$ddzt);
       return View();
   }
}